using System;
using System.Collections.Generic;
using System.Text;

namespace FinancialAnalyzer.ToolClasses
{
    public class Pfad : IComparable<Pfad>
    {
        private String[] _path;
        private readonly Char[] SPLITCHAR = { '\\' };

        private Pfad()
        {
        }

        public Pfad(String pfad)
        {
            _path = pfad.Split(SPLITCHAR);
        }

        public Pfad(String pfad, Char splitchar)
        {
            Char[] newsplitchar = { splitchar };
            _path = pfad.Split(newsplitchar);
        }

        public int Count
        {
            get { return _path.Length; }
        }
        public string this[int i]
        {
            get
            {
                if (i < 0)
                {
                    throw new ArgumentOutOfRangeException("The index was: " + i);
                }
                else
                {
                    return _path[i];
                }
            } 
        }

        public String pathWithBackslash(bool withoutFirstElement, bool withoutLastElement)
        {
            String path = "";
            int i = 0;
            int wall = Count;
            if (withoutFirstElement)
	        {
        		 i = 1;
            }
            if (withoutLastElement)
            {
                wall -= 1;
            }
            for (i = i; i < wall; i++)
            {
                path += this[i]+'\\';
            }
            return path.Substring(0, path.Length - 1);
        }
        
        public String pathWithHyphen(bool withoutFirstElement, bool withoutLastElement)
        {
            String path = "";
            int i = 0;
            int wall = Count;
            if (withoutFirstElement)
	        {
        		 i = 1;
	        }
            if (withoutLastElement)
            {
                wall -=1;
            }
            for (i=i; i < wall; i++)
            {
                path += this[i]+'-';
            }
            return path.Substring(0, path.Length - 1);
        }

        #region IComparable<Pfad> Member

        public int CompareTo(Pfad other)
        {
            int result = 0;
            if (Count < other.Count)
            {
                result = 1;
            }
            else if (Count > other.Count)
            {
                result = -1;
            }
            else
            {
                for (int i = 0; i < Count; i++)
                {
                   if(!this[i].Equals(other[i]))
                   {

                   }
                } 
            }
            return result;
        }

        #endregion
    }
}
